//
//  ViewController.m
//  10505GRB
//
//  Created by student on 16/2/19.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (IBAction)view:(UIControl *)sender {

    [self.textFieldR resignFirstResponder];
    [self.textFieldG resignFirstResponder];
    [self.textFieldB resignFirstResponder];

}

- (void)viewDidLoad {
    
    [super viewDidLoad];
    
    
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)changedColor
{
    [self.background setBackgroundColor: [UIColor colorWithRed:[self.textFieldR.text floatValue]/255.0 green:[self.textFieldG.text floatValue]/255.0 blue:[self.textFieldB.text floatValue]/255.0 alpha:150/255.0]];
}
- (IBAction)SliderR:(UISlider *)sender
{
    int value = sender.value;
    self.textFieldR.text = [NSString stringWithFormat:@"%i",value];
    [self changedColor];
}

- (IBAction)SliderG:(UISlider *)sender
{
    int value = sender.value;
    self.textFieldG.text = [NSString stringWithFormat:@"%i",value];
    [self changedColor];
}

- (IBAction)SliderB:(UISlider *)sender
{
    int value = sender.value;
    self.textFieldB.text = [NSString stringWithFormat:@"%i",value];
    [self changedColor];
}

- (IBAction)textFieldR:(UITextField *)sender
{
    int value = [self.textFieldR.text floatValue];
    [self.sliderRed setValue:value];
    [self changedColor];
    
}

- (IBAction)textFieldG:(UITextField *)sender
{
    int value = [self.textFieldG.text floatValue];
    [self.SliderGreen setValue:value];
    [self changedColor];

}

- (IBAction)textFieldB:(UITextField *)sender
{
    int value = [self.textFieldB.text floatValue];
    [self.SliderBlue setValue:value];
    [self changedColor];

}




@end
